#ifndef EVM_JSON_H
#define EVM_JSON_H

#include "json.hpp"
#include <string>


namespace evm {

using Json = nlohmann::json;

template <typename Type>
bool find(const Json& array, Type item) {
    return find(array.cbegin(), array.cend(), item) != array.cend();
}

/* Helps to get value from json object with a specified key,
 * and if the key is not found, the specified default value is returned. */
template <typename Type>
Type get(const Json& object, std::string key, Type default_ = Type()) {
    if (object.count(key)) {
        return object[key].get<Type>();
    }
    return default_;
}

}

#endif //EVM_JSON_H
